package cn.com.qingz.modules.user.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;

import cn.com.qingz.modules.system.service.impl.GeneralServiceImpl;
import cn.com.qingz.modules.user.mapper.HouseModelMapper;
import cn.com.qingz.modules.user.model.HouseModel;
import cn.com.qingz.modules.user.service.HouseModelService;
import cn.com.qingz.modules.user.vo.HouseModelSearchCondition;

@Service
public class HouseModelServiceImpl  extends GeneralServiceImpl<HouseModel> implements HouseModelService  {
	
	@Autowired
	private HouseModelMapper  housemodelMapper;

	@Override
	public void doAddOrUpdate(HouseModel houseModel) {
		   if (houseModel.getHouseModelId() == null || 0 == houseModel.getHouseModelId()) {
	            mapper.insert(houseModel);
	        } else {
	            mapper.updateByPrimaryKeySelective(houseModel);
	        }
	} 

	public PageList<HouseModel> queryForPage(Object condition, int page, int limit) {
		
		return  housemodelMapper.queryForPage((HouseModelSearchCondition) condition,  new PageBounds(page, limit));
	}


	public Integer doSaveOrUpdate(HouseModel houseModel) {
		if(houseModel.getHouseModelId()== null || houseModel.getHouseModelId() == 0){
			housemodelMapper.insert(houseModel);
			return  houseModel.getHouseModelId();
		}else{
			 return housemodelMapper.updateByPrimaryKeySelective(houseModel);
		}
	}
}
